#pragma once

/*
*	Purpose:
*		This class manages rooms.  It contains a list of rooms and allows that list to be exported, etc.
*		This class also creates Lua Scripts for the rooms.
*
*		The BaseRoom is a room that contains only enough data to export to Lua (ie: enough to generate a room.)
*
*
*		Note: This class also manages Rooms that are used for the grid.
*/

#include "MapGenerator.h"
#include <list>
#include <string>
using namespace std;

bool InRoom(const Vector2D& mos, const Room& room);

struct BaseRoom
{
	Range x1, x2, y1, y2;
	int algorithm, imgID, ID;
	double density;
	string name;

	bool operator ==(const BaseRoom &rhs)
	{
		if(this->ID == rhs.ID)
			return true;
		return false;
	}
};

struct BasePath
{
	BasePath() {ID_a = -1, ID_b = -1, roomID = -1;}

	int roomID; // for removal, since every path is also a room we can just remove a path by removing its room

	int ID_a, ID_b, width, imgID; 
	double smoothingPercentage;
	bool river;

	bool operator ==(const BasePath &rhs)
	{
		if(this->roomID == rhs.roomID)
			return true;
		return false;
	}
};

class RoomManager
{
private:
	list<BasePath> m_ActiveBasePaths;
	list<BasePath> m_NotActiveBasePaths;

	list<BaseRoom> m_BaseRooms;
	list<Room> m_Rooms;


public:
	// Base Rooms
	// Accessors
	list<BaseRoom> GetBaseRooms() {return m_BaseRooms;}
	void AddRoom(const BaseRoom& baseRoom);
	void RemoveRoom(const Room& room);

	void AddPath(const BasePath& basePath, bool activePath);  // Adds a base path to either the active or not active list
	void MergePathLists(); // Places all the not active base paths into the active list
	BasePath GetPath(int roomID); // Returns a basepath that is connected to the ID.  If no path is connected, returns a BasePath with IDs of -1.

	// Exporting
	void ExportToLua(string filename);


	// Rooms
	// Accessors
	void AddRoom(const Room& room);
	list<Room>* GetRooms() {return &m_Rooms;}
	vector<Room*> GetRoomsOnscreen(ClippingPlane *pClippingPlane); // This function returns a list of rooms that are on screen

	
};